<?php
session_start();
include '../inc/connect_db.php';
$rg_username = "";
$rg_email = "";
$rg_password = "";
if(isset($_POST["rg_username"])){
	$rg_username = $_POST["rg_username"];
}
if(isset($_POST["rg_password"])){
	$rg_password = $_POST["rg_password"];
}
if(isset($_POST["rg_email"])){
	$rg_email = $_POST["rg_email"];
}

$sql = "SELECT * FROM tb_user WHERE user_login_name='$rg_username' AND user_password='$rg_password' ";
$query = mysql_query($sql);
$data_count = mysql_num_rows($query);
if($data_count>0){
	echo "0";
}else {
	$sql = "INSERT INTO tb_user(user_login_name,user_email,user_password,user_level) values('$rg_username','$rg_email','$rg_password',0) ";
	mysql_query($sql);
	$_SESSION["username"] = $rg_username;
	echo "1";
}

